<?php

namespace app\web\controller;

use app\common\model\Activity as ActivityModel;
use app\common\model\ActivityItem;
use app\common\model\ActivityItemViper;
use app\common\service\ActivityService;
use app\common\service\FeiEHttpClient;
use app\common\service\FeiEPrintService;
use app\common\service\VoiceService;
use app\web\validate\ActivityValidate;
use plugins\ALiYun\VoiceClass;
use plugins\FeiE\FeiEPrintClass;
use think\Db;

header("Content-type: text/html; charset=utf-8");

/**
 * 设置活动
 * Class FeiEPrint
 * @package app\manage\admin
 */
class FeiEPrint extends Auth
{

    //<BR> ：换行符
    //<CUT> ：切刀指令(主动切纸,仅限切刀打印机使用才有效果)
    //<LOGO> ：打印LOGO指令(前提是预先在机器内置LOGO图片)
    //<PLUGIN> ：钱箱或者外置音响指令
    //<CB></CB>：居中放大
    //<B></B>：放大一倍
    //<C></C>：居中
    //<L></L>：字体变高一倍
    //<W></W>：字体变宽一倍
    //<QR></QR>：二维码（单个订单，最多只能打印一个二维码）
    //<RIGHT></RIGHT>：右对齐
    //<BOLD></BOLD>：字体加粗
    //
    //说明：来订单时默认播放新来单语音，若使用“申请退单”或“申请取消订单”的语音，请使用以下指令
    //<AUDIO-REFUND>：申请退单语音指令。播报内容为：有用户申请退单了
    //<AUDIO-CANCEL>：申请取消订单语音指令。播报内容为：有用户申请取消订单了
    //
    //说明：条形码标签仅支持以下标签规定的内容打印，如需要打印其它特殊字符条形码，需要点击后面的 飞鹅云条形码函数按钮
    //下载条形码函数进行调用打印
    //<BC128_A>123ABCDEF</BC128_A>：数字字母混合条形码,最多支持14位数字大写字母混合
    //<BC128_C>0123456789</BC128_C>：最多支持22位纯数字

    /**
     * 打印手机结账账单
     */
    public function printPhoneBill() {

        if ($this->request->isPost()) {

            $fei_e_sn = Db::name('qt_store_printer')->where('store_id',$this->userInfo['store_id'])->value('sn');
            if (empty($fei_e_sn)) {
                $this->result('没有找到打印机数据','',204);
            }

            $post = $this->request->post();
            $item = Db::name('qt_check_out')
                ->alias('out')
                ->field([
                    'out.id',//结账单ID
                    'out.order_no',//账单号
                    'out.is_revoke',//状态
                    'out.revoke_time',//撤销时间
                    'out.revoke_person',//撤销人
                    'out.revoke_remarks',//撤销备注
                    'out.cashier_id',//结账人
                    'out.cashier_time',//结账时间
                    'out.pay_content',//付款方式
                    'out.total_money',//总金额
                    'out.payment_money',//实际支付
                    'out.project_order',//项目订单
                    'out.goods_order',//商品订单
                    'out.uv_id',//商品订单
                ])
                ->where([
                    'out.id'=>$post['check_out_id'],
                    'out.store_id'=> $this->userInfo['store_id'],
                ])->find();
            if (empty($item)) {
                $this->result('没有找到数据','',204);
            }
            $item['project_detail'] = [];//项目
            $item['product_detail'] = [];//商品
            $item['cashier_name'] = Db::name('qt_users')->where('id', $item['cashier_id'])->value('real_name');//结账人

            //结账详情
            $item_data = Db::name('qt_check_out_item')->where('check_out_id', $item['id'])->select();
            if (empty($item_data)) {
                $this->result('没有找到结账单详情数据','',204);
            }
            //echo "</pre>";
            //print_r($item_data);
            //exit;

            foreach ($item_data as $key => $val) {
                $data = [];
                //项目
                if (!empty($val['link_type']) && $val['link_type'] == 1) {

                    $project_data = Db::name('qt_order_project')
                        ->where('project_id', $val['link_id'])
                        ->where('is_delete',2)
                        ->whereIn('order_id',explode(',',$item['project_order']))
                        ->column('id,room_id,engineer_id,project_id,hand_card_id,name as project_name,order_type,is_add,num,price,payment_price,start_time,real_end_time,created_time', 'project_id');


                    if (empty( $project_data[$val['link_id']] )) {
                        continue;
                    }
                    $project_item = $project_data[$val['link_id']];


                    $data['project_name'] = $project_item['project_name'] ?? '';
                    $engineer_data =  Db::name('qt_users')->where('id', $project_item['engineer_id'])->find();
                    $data['engineer_name'] = $engineer_data['real_name'] ??'';
                    $data['work_number'] = $engineer_data['work_number'] ??'';
                    $data['engineer_id'] = $project_item['engineer_id'] ?? '';
                    $data['hand_card_name'] = Db::name('qt_hand_card')->where('id',$project_item['hand_card_id'])->value('name') ??'';

                    $data['room_id'] = $project_item['room_id'] ?? '';
                    $data['room_name'] = Db::name('qt_room')->where('id', $project_item['room_id'])->value('name') ?? '';
                    $data['order_type'] = $project_item['order_type'] ?? '';
                    $data['is_add'] = $project_item['is_add'] ?? '';

                    $data['num'] = $project_item['num']??'';
                    $data['total_price'] = $project_item['price']??'';
                    $data['payment_price'] = $project_item['payment_price']??'';
                    $data['created_time'] = $project_item['created_time']??0;
                    $data['real_end_time'] = $project_item['real_end_time']??0;
                    $data['start_time'] = $project_item['start_time']??0;

                    $item['project_detail'][] = $data;
                }


                //商品
                if (!empty($val['link_type']) && $val['link_type'] == 2) {
                    $product_data = Db::name('qt_product_order_item')
                        ->alias('i')
                        ->leftJoin('qt_product_order o','i.order_id=o.id')
                        ->where('o.id', explode(',',$item['goods_order']))//订单ID
                        ->where(['i.status'=>'1'])
                        ->where('i.goods_id', $val['link_id'])//订单ID
                        ->column('o.id,o.room_id,o.engineer_id,i.goods_id as project_id,o.hand_card_id,
                        i.goods_name as project_name,o.total_price,o.payment_price,i.create_time,i.business_type', 'i.goods_id');
                    //echo "</pre>";
                    //print_r($product_data);
                    //exit;
                    if (empty($product_data[$val['link_id']])) {
                        continue;
                    }
                    $product_item = $product_data[$val['link_id']];

                    $engineer_data =  Db::name('qt_users')->where('id', $product_item['engineer_id'])->find();//技师
                    $data['engineer_name'] = $engineer_data['real_name'] ??'';
                    $data['work_number'] = $engineer_data['work_number'] ??'';
                    $data['engineer_id'] = $product_item['engineer_id'] ?? '';
                    $data['hand_card_name'] = Db::name('qt_hand_card')->where('id',$product_item['hand_card_id'])->value('name')??'';

                    $data['project_name'] = $product_item['project_name'] ?? '';
                    $data['room_id'] = $product_item['room_id'] ?? '';
                    $data['room_name'] = Db::name('qt_room')->where('id', $product_item['room_id'])->value('name') ?? '';
                    $data['order_type'] = '';
                    $data['is_add'] = '';
                    $data['num'] = $product_item['goods_num']??'';
                    $data['total_price'] = $product_item['total_price']??'';
                    $data['payment_price'] = $product_item['payment_price']??'';
                    $data['create_time'] = $product_item['create_time']??'';
                    $data['business_type'] = $product_item['business_type']??'';
                    $item['product_detail'][] = $data;
                }
            }
            $store_name = Db::name('qt_store')->where('id',$this->userInfo['store_id'])->value('name');
            $print_class = new FeiEPrintClass();
            $content  = '<CB>'.$store_name.'账单</CB><BR>';
            $content .= '<C>欢迎观临</C><BR>';
            $content .= '<BOLD>结账单号：'.$item['order_no'].'</BOLD><BR>';
            $content .= '<BOLD>结账人：'.$item['cashier_name'].'</BOLD><BR>';
            $content .= '<BOLD>结账时间：'.date('Y-m-d H:i:s',$item['cashier_time']).'</BOLD><BR>';
            $content .= '<BOLD>打印时间：'.date('Y-m-d H:i:s',time()).'</BOLD><BR>';
            $content .= '<BOLD>开房时间：'.date('Y-m-d H:i:s',$item['cashier_time']).'</BOLD><BR>';//TODO
            $content .= '---------------------------------------------<BR>';
            $content .= '房间  技师　　　　项目        数量  金额  实收 <BR>';
            $content .= '---------------------------------------------<BR>';

            //echo "</pre>";
            //print_r($item);
            //exit;
            $total_price = 0;
            $payment_price = 0;
            foreach ($item['project_detail'] as $k => $v) {
                $v['total_price'] = empty($v['total_price']) ? 0 : $v['total_price'];
                $total_price = $total_price + $v['total_price'];
                $v['payment_price'] = empty( $v['payment_price']) ? 0 :  $v['payment_price'];
                $payment_price = $payment_price + $v['payment_price'];
                $content .= "{$v['room_name']}  {$v['work_number']}　    {$v['project_name']}    {$v['num']}    {$v['total_price']}   {$v['payment_price']}  <BR>";
            }
            foreach ($item['product_detail'] as $key => $val) {
                $v['total_price'] = empty($v['total_price']) ? 0 : $v['total_price'];
                $total_price = $total_price + $v['total_price'];
                $v['payment_price'] = empty( $v['payment_price']) ? 0 :  $v['payment_price'];
                $payment_price = $payment_price + $v['payment_price'];
                $fang_fei = $val['business_type'] = 2 ? '【房费】' : '';
                $content .= "{$val['room_name']}  {$val['work_number']}　    {$fang_fei}{$val['project_name']}    {$val['num']}    {$val['total_price']}   {$val['payment_price']}  <BR>";
            }

            $pay_content = json_decode($item['pay_content'],true);

            $phone = Db::name('qt_users')->where('id',$item['uv_id'])->value('phone');
            $content .= '---------------------------------------------<BR>';
            $content .= "                 合计：　　　     {$total_price} {$payment_price}  <BR>";
            $content .= '套餐信息 <BR>';
            $content .= ' 足疗 ￥1000 <BR>';
            $content .= '付款说明 <BR>';
            $content .=  $pay_content[0]['pay_type'].":" .$pay_content[0]['pay_money']."<BR>";
            $content .= "预约电话： {$phone} <BR>";

            var_dump($content);exit();

            $result = $print_class->printMsg($fei_e_sn,$content,1);
            $result = json_decode($result,true);
            if ($result['ret'] == 0) {
                $this->result('打印成功', $result['data'], 200);
            }else {
                $this->result('打印失败', $result['data'], 204);
            }
        }
        $this->result('无效的请求', '', 204);
    }


    /**
     * 打印手机充值账单
     */
    public function printPhoneEntry() {

        if ($this->request->isPost()) {

            $fei_e_sn = Db::name('qt_store_printer')->where('store_id',$this->userInfo['store_id'])->value('sn');
            if (empty($fei_e_sn)) {
                $this->result('没有找到打印机数据','',204);
            }
            // 表单数据
            $post = $this->request->post();
            $card_data = Db::name('qt_viper_card_recharge_log')->alias('log')
                ->field([
                    'log.*',
                    'qvc.card_no',
                    'qvt.name as card_type_name',
                    'qvt.give_total_amount',//赠送总金额
                    'qvt.give_amount',
                    'qvt.total_amount',
                    'qvt.amount',//会员余额 可用余额
                ])
                ->leftJoin('qt_viper_card qvc','log.viper_card_id = qvc.id')
                ->leftJoin('qt_viper_type qvt','qvc.viper_type_id = qvt.id')
                ->where('id',$post['viper_card_id'])->where('id',$post['id'])->find();

            $store_name = Db::name('qt_store')->where('store_id',$card_data['store_id'])->value('name')??'';
            $real_name = Db::name('qt_users')->where('id',$card_data['user_id'])->value('real_name')??'';

            if ($card_data['card_type'] == 1) {
               $template_data = Db::name('qt_viper_recharge_template')->where(['id'=>$card_data['recharge_tempid']])->find();
            }
            if ($card_data['card_type'] == 2) {
                $template_data = Db::name('qt_viper_number_card_template')->where(['id'=>$card_data['recharge_tempid']])->find();
            }
            if ($card_data['card_type'] == 3) {
                $template_data = Db::name('qt_viper_month_card_template')->where(['id'=>$card_data['recharge_tempid']])->find();
            }
            $pay_type_config = Db::name('qt_pay_type')->column('id,name','id');

            $sale_data = Db::name('qt_users')->where('id',$card_data['sale_id'])->find();

            //上次余额
            $money_log_data = Db::name('qt_viper_money_log')->where([
                'order_id'=>$card_data['id'],
                'type'=>1,//变更类型 1 充值 2 转账 3 消费
                'flag'=>1,//类型 1=账户余额 2=积分 3 赠送金额
            ])->find();
            $last_balance = !empty($money_log_data) ? $money_log_data['after_money'] - $money_log_data['money'] : 0 ;

            $print_class = new FeiEPrintClass();
            $content  = '<CB>会员卡充值单</CB><BR>';
            $content .= '<C>单号：'.$card_data['card_no'].'</C><BR>';
            $content .= '<BOLD>打印时间：　　　　　    '.date('Y-m-d H:i:s').'</BOLD><BR>';
            $content .= '<BOLD>充值时间：　　　　　    '.date('Y-m-d H:i:s').'</BOLD><BR>';
            $content .= '电话：　　　　　             '.$card_data['mobile'].'<BR>';
            $content .= '卡类型：       　　　　　          '.$card_data['card_type_name'].'<BR>';
            $content .= '卡号：　　　　　        '.$card_data['card_no'].'<BR>';
            $content .= '所属门店：                        '.$store_name.'<BR>';
            $content .= '姓名：　　　　　                  '.$real_name.'<BR>';
            $content .= '---------------------------------------------<BR>';
            $content .= '充值模版：　　　　　          '.$template_data['name']??''.'<BR>';
            $content .= '充值金额：　　　　　                  '.$template_data['amount']??''.'<BR>';
            $content .= '赠送金额：　　　　　                   '.$card_data['give_amount'].'<BR>';
            $content .= '入卡金额：　　　　　                  '.$card_data['card_amount'].'<BR>';
            $content .= '上次余额：　　　　　                     '.$last_balance.'<BR>';
            $content .= '本金余额：　　　　　                     '.$card_data['amount'].'<BR>';
            $content .= '赠送金余额：　　　　　                 '.$card_data['give_total_amount'].'<BR>';
            $content .= '可用余额：　　　　　                  '.$card_data['amount'].'<BR>';
            $content .= '销售人：　　　　　               '.$sale_data['work_number'].'('.$sale_data['real_name'].')'.'<BR>';
            $content .= '--------------------------------------------<BR>';
            $content .= '付款说明：　　　　　            '.$card_data['recharge_content'].'<BR>';
            $content .= $pay_type_config[$card_data['pay_type']].'：'.$card_data['card_amount'].'<BR>';
            $content .= '--------------------------------------------<BR>';
            $content .= '单注/签字：____________________________<BR>';

            var_dump($content);exit();
            $result = $print_class->printMsg($fei_e_sn,$content,1);
            $result = json_decode($result,true);
            if ($result['ret'] == 0) {
                $this->result('打印成功', $result['data'], 200);
            }else {
                $this->result('打印失败', $result['data'], 204);
            }
        }
        $this->result('无效的请求', '', 204);

    }


    /**
     * 打印水吧单据
     */
    public function printWaterBar() {

        if ($this->request->isPost()) {

            $post = $this->request->post();
            $fei_e_sn = Db::name('qt_store_printer')->where('store_id',$this->userInfo['store_id'])->value('sn');
            if (empty($fei_e_sn)) {
                $this->result('没有找到打印机数据','',204);
            }

            $item = Db::name('qt_check_out')
                ->alias('out')
                ->field([
                    'out.id',//结账单ID
                    'out.order_no',//账单号
                    'out.is_revoke',//状态
                    'out.revoke_time',//撤销时间
                    'out.revoke_person',//撤销人
                    'out.revoke_remarks',//撤销备注
                    'out.cashier_id',//结账人
                    'out.cashier_time',//结账时间
                    'out.pay_content',//付款方式
                    'out.total_money',//总金额
                    'out.payment_money',//实际支付
                    'out.project_order',//项目订单
                    'out.goods_order',//商品订单
                    'out.uv_id',//商品订单
                ])
                ->where([
                    'out.id'=>$post['check_out_id'],
                    'out.store_id'=> $this->userInfo['store_id'],
                ])->find();
            if (empty($item)) {
                $this->result('没有找到数据','',204);
            }

            $item['project_detail'] = [];//项目
            $item['product_detail'] = [];//商品
            $item['cashier_name'] = Db::name('qt_users')->where('id', $item['cashier_id'])->value('real_name');//结账人

            //结账详情
            $item_data = Db::name('qt_check_out_item')->where('check_out_id', $item['id'])->select();
            if (empty($item_data)) {
                $this->result('没有找到结账单详情数据','',204);
            }

            foreach ($item_data as $key => $val) {
                $data = [];
                //项目
                if (!empty($val['link_type']) && $val['link_type'] == 1) {

                    $project_data = Db::name('qt_order_project')
                        ->where('project_id', $val['link_id'])
                        ->where('is_delete',2)
                        ->whereIn('order_id',explode(',',$item['project_order']))
                        ->column('id,room_id,engineer_id,project_id,hand_card_id,name as project_name,order_type,is_add,num,price,payment_price,start_time,real_end_time,created_time', 'project_id');


                    if (empty( $project_data[$val['link_id']] )) {
                        continue;
                    }
                    $project_item = $project_data[$val['link_id']];


                    $data['project_name'] = $project_item['project_name'] ?? '';
                    $engineer_data =  Db::name('qt_users')->where('id', $project_item['engineer_id'])->find();
                    $data['engineer_name'] = $engineer_data['real_name'] ??'';
                    $data['work_number'] = $engineer_data['work_number'] ??'';
                    $data['engineer_id'] = $project_item['engineer_id'] ?? '';
                    $data['hand_card_name'] = Db::name('qt_hand_card')->where('id',$project_item['hand_card_id'])->value('name') ??'';

                    $data['room_id'] = $project_item['room_id'] ?? '';
                    $data['room_name'] = Db::name('qt_room')->where('id', $project_item['room_id'])->value('name') ?? '';
                    $data['order_type'] = $project_item['order_type'] ?? '';
                    $data['is_add'] = $project_item['is_add'] ?? '';

                    $data['num'] = $project_item['num']??'';
                    $data['total_price'] = $project_item['price']??'';
                    $data['payment_price'] = $project_item['payment_price']??'';
                    $data['created_time'] = $project_item['created_time']??0;
                    $data['real_end_time'] = $project_item['real_end_time']??0;
                    $data['start_time'] = $project_item['start_time']??0;

                    $item['project_detail'][] = $data;
                }


                //商品
                if (!empty($val['link_type']) && $val['link_type'] == 2) {

                    $product_data = Db::name('qt_product_order_item')
                        ->alias('i')
                        ->leftJoin('qt_product_order o','i.order_id=o.id')
                        ->where('o.id', explode(',',$item['goods_order']))//订单ID
                        ->where('i.goods_id', $val['link_id'])//订单ID
                        ->where(['i.status'=>'1'])
                        ->column('o.id,o.room_id,o.engineer_id,i.goods_id as project_id,o.hand_card_id,
                        i.goods_name as project_name,o.total_price,o.payment_price,i.create_time,i.business_type', 'i.goods_id');
                    //echo "</pre>";
                    //print_r($product_data);
                    //exit;
                    if (empty($product_data[$val['link_id']])) {
                        continue;
                    }
                    $product_item = $product_data[$val['link_id']];

                    $engineer_data =  Db::name('qt_users')->where('id', $product_item['engineer_id'])->find();//技师
                    $data['engineer_name'] = $engineer_data['real_name'] ??'';
                    $data['work_number'] = $engineer_data['work_number'] ??'';
                    $data['engineer_id'] = $product_item['engineer_id'] ?? '';
                    $data['hand_card_name'] = Db::name('qt_hand_card')->where('id',$product_item['hand_card_id'])->value('name')??'';


                    $data['project_name'] = $product_item['project_name'] ?? '';
                    $data['room_id'] = $product_item['room_id'] ?? '';
                    $data['room_name'] = Db::name('qt_room')->where('id', $product_item['room_id'])->value('name') ?? '';
                    $data['order_type'] = '';
                    $data['is_add'] = '';
                    $data['num'] = $product_item['goods_num']??'';
                    $data['total_price'] = $product_item['total_price']??'';
                    $data['payment_price'] = $product_item['payment_price']??'';
                    $data['create_time'] = $product_item['create_time']??'';
                    $data['business_type'] = $product_item['business_type']??'';
                    $item['product_detail'][] = $data;
                }
            }

            $store_name = Db::name('qt_store')->where('id',$this->userInfo['store_id'])->value('name');
            $print_class = new FeiEPrintClass();
            $content  = '<CB>'.$store_name.'账单</CB><BR>';
            $content .= '<C>欢迎观临</C><BR>';
            $content .= '<BOLD>结账单号：'.$item['order_no'].'</BOLD><BR>';
            $content .= '<BOLD>结账人：'.$item['cashier_name'].'</BOLD><BR>';
            $content .= '<BOLD>结账时间：'.date('Y-m-d H:i:s',$item['cashier_time']).'</BOLD><BR>';
            $content .= '<BOLD>打印时间：'.date('Y-m-d H:i:s',time()).'</BOLD><BR>';
            $content .= '<BOLD>开房时间：'.date('Y-m-d H:i:s',$item['cashier_time']).'</BOLD><BR>';//TODO
            $content .= '---------------------------------------------<BR>';
            $content .= '房间  技师　　　　项目        数量  金额  实收 <BR>';
            $content .= '---------------------------------------------<BR>';
            $content .= "手牌：{} 发放时间：{}  <BR>";
            $content .= '---------------------------------------------<BR>';


            $total_price = 0;
            $payment_price = 0;
            foreach ($item['project_detail'] as $k => $v) {
                $v['total_price'] = empty($v['total_price']) ? 0 : $v['total_price'];
                $total_price = $total_price + $v['total_price'];
                $v['payment_price'] = empty( $v['payment_price']) ? 0 :  $v['payment_price'];
                $payment_price = $payment_price + $v['payment_price'];
                $content .= "{$v['room_name']}  {$v['work_number']}　    {$v['project_name']}    {$v['num']}    {$v['total_price']}   {$v['payment_price']}  <BR>";
            }
            foreach ($item['product_detail'] as $key => $val) {
                $v['total_price'] = empty($v['total_price']) ? 0 : $v['total_price'];
                $total_price = $total_price + $v['total_price'];
                $v['payment_price'] = empty( $v['payment_price']) ? 0 :  $v['payment_price'];
                $payment_price = $payment_price + $v['payment_price'];
                $fang_fei = $val['business_type'] == 2 ? '【房费】' : '';
                $content .= "{$val['room_name']}  {$val['work_number']}　    {$fang_fei}{$val['project_name']}    {$val['num']}    {$val['total_price']}   {$val['payment_price']}  <BR>";
            }
            //echo "</pre>";
            //print_r($item);
            //exit;

            $pay_content = json_decode($item['pay_content'],true);
            $user_data = Db::name('qt_users')->alias('user')
                ->field([
                    'user.*',
                    'qvc.*',
                    'qvt.name as viper_type_name',
                ])
                ->leftJoin('qt_viper_card qvc','user.id = qvc.user_id')
                ->leftJoin('qt_viper_type qvt','qvc.viper_type_id=qvt.id')
                ->where('user.id',$item['uv_id'])
                ->find();
            $content .= '                           小计   58   123  <BR>';
            $content .= '---------------------------------------------<BR>';
            $content .= "                 合计：　　　     {$total_price} {$payment_price}  <BR>";
            $content .= '付款说明 <BR>';
            $content .=  $pay_content[0]['pay_type'].":" .$pay_content[0]['pay_money']."<BR>";
            $content .= ' 折免： 800 <BR>';
            $content .= '---------------------------------------------<BR>';
            $content .= "会员卡号：{$user_data['card_no']} <BR>";
            $content .= "卡类型：{$user_data['viper_type_name']} <BR>";
            $content .= "电话：{$user_data['phone']} <BR>";
            $content .= '会员本金支付：1200 <BR>';
            $content .= '会员赠送支付：200 <BR>';
            $content .= '折扣：100 <BR>';
            $content .= '本金余额：100 <BR>';
            $content .= '赠送余额：100 <BR>';
            $content .= '可用余额：100 <BR>';
            $content .= '可用积分：100 <BR>';
            $content .= '次卡剩余：1 <BR>';
            $content .= "预约电话： {$user_data['phone']} <BR>";

            var_dump($content);exit();
            $result = $print_class->printMsg($fei_e_sn,$content,1);
            $result = json_decode($result,true);
            if ($result['ret'] == 0) {
                $this->result('打印成功', $result['data'], 200);
            }else {
                $this->result('打印失败', $result['data'], 204);
            }
        }
        $this->result('无效的请求', '', 204);

    }



    /**
     * 鞋吧打印
     */
    public function printShoes() {
        if ($this->request->isPost()) {

            $fei_e_sn = Db::name('qt_store_printer')->where('store_id',$this->userInfo['store_id'])->value('sn');
            if (empty($fei_e_sn)) {
                $this->result('没有找到打印机数据','',204);
            }
            $post = $this->request->post();
            $print_class = new FeiEPrintClass();
            $content = '';

            $result = $print_class->printMsg('570802565',$content,1);
            $result = json_decode($result,true);
            if ($result['ret'] == 0) {
                $this->result('打印成功', $result['data'], 200);
            }else {
                $this->result('打印失败', $result['data'], 200);
            }
        }
        $this->result('无效的请求', '', 204);
    }

}